import React from 'react';
import { Row, Col, Form, Input, Select, Button, Modal, Spin } from 'antd';

const FormItem = Form.Item;

const formLayout = {
  labelCol: { span: 6 },
  wrapperCol: { span: 14 },
};

// @connect(({ loading }) => ({
// }))
export default class InvADJModal extends React.Component<any, any> {
  handleSubmit = (values:any) => {
    const { onSubmit} = this.props;
    if (typeof onSubmit === 'function') {
      onSubmit(values);
    }
  };
  formRender = () => {
    const { formVals = {} } = this.props;

    return (
      <Form {...formLayout} initialValues={formVals} onFinish={this.handleSubmit}>
        <Row gutter={16}>
          <Col span={24}>
            <FormItem name="adjustment" label="调整原因">
              <Input placeholder="请输入调整原因" />
            </FormItem>
          </Col>
          <Col span={24}>
            <FormItem name="count" label="数量">
              <Input placeholder="请输入数量" />
            </FormItem>
          </Col>
          <Col span={24} style={{ display: 'flex', justifyContent: 'center' }}>
            <Button type="primary" htmlType="submit">
              确认
            </Button>
          </Col>
        </Row>
      </Form>
    );
  };
  render() {
    const { visible, onCancel, loading = false } = this.props;

    const FormRender = this.formRender;

    return (
      <Modal
        title='数量调整'
        width="640px"
        bodyStyle={{ padding: 24 }}
        visible={visible}
        destroyOnClose
        footer={null}
        onCancel={() => onCancel()}
      >
        <Spin spinning={loading}>
          <FormRender />
        </Spin>
      </Modal>
    );
  }
}
